<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:param name="MessageRank"/>
  <xsl:param name="LoggerName"/>

  <xsl:template match="/">

    <html>
      <head>
        <title>Log File Viewer</title>
      </head>
      <body>
        <font size="10">
          <table border="1" width="100%" cellspacing="0" cellpadding="4" bordercolorlight="#000000" bordercolordark="#ffffff" bordercolor="#000000">
            <thead>
              <tr>
                <th width="3%" style="height: 21px;text-align: left;" bgcolor="#000000">
                  <font size="2" face="Arial" color="#FFFFFF">
                    <b>
                      <center>#</center>
                    </b>
                  </font>
                </th>
                <th colspan="2" width="43%" style="height: 21px;text-align: left;" bgcolor="#000000" >

                  <font size="2" face="Arial" color="#FFFFFF">
                    <b>
                      <center>Time</center>
                    </b>
                  </font>
                </th>
                <th style="height: 21px;" bgcolor="#000000" colspan="3">

                  <font size="2" face="Arial" color="#FFFFFF">
                    <b>
                      <center>Logger Name</center>
                    </b>
                  </font>
                </th>
                <th style="height: 21px;" bgcolor="#000000" colspan="3">

                  <font size="2" face="Arial" color="#FFFFFF">
                    <b>
                      <center>Priority</center>
                    </b>
                  </font>
                </th>
              </tr>
            </thead>
            <tbody>
              <xsl:apply-templates select="logfile/event"/>
            </tbody>
          </table>
        </font>
      </body>
    </html>

  </xsl:template>

  <xsl:template match="event">

    <!--<xsl:value-of select="contains(rank,$MessageRank)"/>
    $MessageRank="Debug&Info"
    -->
    <xsl:if test="contains($MessageRank,rank)">
      <xsl:if test="contains($LoggerName,logger_name)">

        <xsl:choose>
          <xsl:when test="rank='Debug'">
            <tr bgcolor="#82D55E" valign="middle" align="left">
              <td width="3%">

                <xsl:value-of select="n"/>

              </td>
              <td width="43%" colspan="2" >
                <xsl:value-of select="time"/>
              </td>
              <td colspan="3" >
                <xsl:value-of select="logger_name"/>
              </td>
              <td>
                <xsl:value-of select="rank"/>
              </td>
            </tr>
            <tr bgcolor="#82D55E" valign="middle" align="left">
              <td bgcolor="#FFFFFF">

              </td>
              <td colspan="6">
                <b>
                  <xsl:if test="message=''">
                    <p align="center">-</p>
                  </xsl:if>
                  <xsl:if test="message!=''">
                    <xsl:value-of select="message"/>
                  </xsl:if>
                </b>
              </td>
            </tr>
          </xsl:when>

          <xsl:when test="rank='Info'">
            <tr bgcolor="#8CD0E1" valign="middle" align="left">
              <td width="3%">
                <xsl:value-of select="n"/>
              </td>
              <td width="43%" colspan="2" >
                <xsl:value-of select="time"/>
              </td>
              <td colspan="3" >
                <xsl:value-of select="logger_name"/>
              </td>
              <td>
                <xsl:value-of select="rank"/>
              </td>
            </tr>
            <tr bgcolor="#8CD0E1" valign="middle" align="left">
              <td bgcolor="#FFFFFF">

              </td>
              <td colspan="6">
                <b>
                  <xsl:if test="message=''">
                    <p align="center">-</p>
                  </xsl:if>
                  <xsl:if test="message!=''">
                    <xsl:value-of select="message"/>
                  </xsl:if>
                </b>
              </td>
            </tr>
          </xsl:when>

          <xsl:when test="rank='Warning'">
            <tr bgcolor="#F9AF1F" valign="middle" align="left">
              <td width="3%">
                <xsl:value-of select="n"/>
              </td>
              <td width="43%" colspan="2" >
                <xsl:value-of select="time"/>
              </td>
              <td colspan="3" >
                <xsl:value-of select="logger_name"/>
              </td>
              <td  align="center">
                <xsl:value-of select="rank"/>
              </td>
            </tr>
            <tr bgcolor="#F9AF1F" valign="middle" align="left">
              <td bgcolor="#FFFFFF">

              </td>
              <td colspan="6">
                <b>
                  <xsl:if test="message=''">
                    <p align="center">-</p>
                  </xsl:if>
                  <xsl:if test="message!=''">
                    <xsl:value-of select="message"/>
                  </xsl:if>
                </b>
              </td>
            </tr>
          </xsl:when>

          <xsl:when test="rank='Error'">
            <tr bgcolor="#FFAA80" valign="middle" align="left">
              <td width="3%">
                <xsl:value-of select="n"/>
              </td>
              <td width="43%" colspan="2" >
                <xsl:value-of select="time"/>
              </td>
              <td colspan="3" >
                <xsl:value-of select="logger_name"/>
              </td>
              <td align="center">
                <xsl:value-of select="rank"/>
              </td>
            </tr>
            <tr bgcolor="#FFAA80" valign="middle" align="left">
              <td bgcolor="#FFFFFF">

              </td>
              <td colspan="6">
                <b>
                  <xsl:if test="message=''">
                    <p align="center">-</p>
                  </xsl:if>
                  <xsl:if test="message!=''">
                    <xsl:value-of select="message"/>
                  </xsl:if>
                </b>
              </td>
            </tr>
          </xsl:when>
          <xsl:when test="rank='Critical'">
            <tr bgcolor="#F91FDD" valign="middle" align="left">
              <td width="3%">
                <xsl:value-of select="n"/>
              </td>
              <td width="43%" colspan="2" >
                <xsl:value-of select="time"/>
              </td>
              <td colspan="3" >
                <xsl:value-of select="logger_name"/>
              </td>
              <td align="center">
                <xsl:value-of select="rank"/>
              </td>
            </tr>
            <tr bgcolor="#F91FDD" valign="middle" align="left">
              <td bgcolor="#FFFFFF">

              </td>
              <td colspan="6">
                <b>
                  <xsl:if test="message=''">
                    <p align="center">-</p>
                  </xsl:if>
                  <xsl:if test="message!=''">
                    <xsl:value-of select="message"/>
                  </xsl:if>
                </b>
              </td>
            </tr>
          </xsl:when>

          <xsl:when test="rank='Exception'">
            <tr bgcolor="#EE3131" valign="middle" align="left">
              <td width="3%">
                <xsl:value-of select="n"/>

              </td>
              <td width="43%" colspan="2" >
                <xsl:value-of select="time"/>
              </td>
              <td colspan="3" >
                <xsl:value-of select="logger_name"/>
              </td>
              <td align="center">
                <xsl:value-of select="rank"/>
              </td>
            </tr>
            <tr bgcolor="#EE3131" valign="middle" align="left">
              <td bgcolor="#FFFFFF">
              </td>
              <td colspan="6">
                <b>
                  <xsl:if test="message=''">
                    <p align="center">-</p>
                  </xsl:if>
                  <xsl:if test="message!=''">
                    <xsl:value-of select="message"/>
                  </xsl:if>
                </b>
              </td>
            </tr>
            <xsl:if test="exception_information!='null'">
              <xsl:apply-templates select="exception_information"/>
            </xsl:if>

          </xsl:when>

        </xsl:choose>

      </xsl:if>
    </xsl:if>
  </xsl:template>

  <xsl:template match="exception_information">

    <!-- HEAD FOR EXCEPTION BLOCK-->
    <tr bgcolor="#EE3131" valign="middle" align="left">
      <td bgcolor="#FFFFFF">
      </td>
      <th colspan="1" style="text-align: center">
        Assembly Name
      </th>
      <th colspan="2" style="text-align: center">
        Call Stack
      </th>
      <th colspan="2" style="text-align: center">
        Inner Message
      </th>
      <th colspan="1" style="text-align: center">
        PrintScreen File Name
      </th>
    </tr>
    <!-- /HEAD FOR EXCEPTION BLOCK-->
    <!-- EXCEPTION BLOCK-->
    <tr bgcolor="#EE3131" valign="middle" align="left">
      <td  bgcolor="#FFFFFF">
      </td>
      <td colspan="1">
        <xsl:value-of select="assembly_name"/>
      </td>
      <td colspan="2">
       <xsl:value-of select="call_stack"/>
      </td>
      <td colspan="2">
        <xsl:if test="inner_message=''">
          <p align="center">-</p>
        </xsl:if>
        <xsl:if test="inner_message!=''">
          <xsl:value-of select="inner_message"/>
        </xsl:if>
      </td>
      <td colspan="1">
        <xsl:if test="prt_scr_file_name=''">
          <p align="center">-</p>
        </xsl:if>
        <xsl:if test="prt_scr_file_name!=''">
        <xsl:value-of select="prt_scr_file_name"/>
        </xsl:if>
      </td>
    </tr>
    <!-- /EXCEPTION BLOCK-->
  </xsl:template>

</xsl:stylesheet>